package com.java.producer;

import com.java.channel.MyProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * @ClassNameMessageSender
 * @Description
 * @Author liufei
 * @Date2021/9/6 16:57
 * @Version V1.0
 **/
@EnableBinding(MyProcessor.class)
@Component
public class MessageSender {
    @Autowired
    @Qualifier(value = "myoutput")
    private MessageChannel myoutput;

    public void send(Object object){
        myoutput.send(MessageBuilder.withPayload(object).build());
    }
}
